/**
* Plugin which uses the Google AJAX Feed API for creating feed content
* @author: M. Alsup (malsup at gmail dot com)
* @version: 1.0.2 (5/11/2007)
* Documentation and examples at: http://www.malsup.com/jquery/gfeed/
* Free beer and free speech. Enjoy!
*/
(function($) {
	if (!window.google) {
		alert('You must include the Google AJAX Feed API script');
		return;
	}
	if (!google.feeds) google.load("feeds", "1");
	$.fn.vFeed = function(options) {
		var opts = jQuery.extend({
			target: this,
			vcont : true,
			max   : 5 // max number of items per feed
		}, options || {});
		function pubDate(dateStr){
			var ent = dateStr.split(/\s/g);
			return ent[1]+' '+ent[2]+' '+ent[3]+ ' ' +ent[4];
		}
		function resLoaded(result){
			//alert(JSON.stringify(result));
			$(opts.target).each(function() {
				var fillEl = $(this);
				//var entStr = '';
				var tot = result.feed.entries.length;
				if (tot<=0) return this;
				for (var i = 0; i < result.feed.entries.length; i++) {
					var entry = result.feed.entries[i];
					/*
					entStr = entStr + '<a href="'+entry.link+'" target="_blank">'+entry.title+'</a><br>'+
					pubDate(entry.publishedDate) + '<br>' +
					((opts.vcont)?entry.content:'') + 
					'<br><hr><br>';
					*/
					
					jQuery('<a href="'+entry.link+'" rel="shadowbox" target="_blank">'+entry.title+'</a>').appendTo(fillEl).click(function(e){
					//jQuery('<a href="'+entry.link+'" rel="shadowbox">'+entry.title+'</a>').appendTo(fillEl).click(function(e){
					//jQuery('<a href="'+entry.link+'">'+entry.title+'</a>').appendTo(fillEl).click(function(e){
						
						//e.preventDefault();
						//var urlDest = jQuery(this).attr('href');
						
						//Shadowbox.open({content : urlDest, player: 'iframe'});
						//Shadowbox.open({content : '<marquee>Tes yoooo</marquee>', player: 'html'});
						//alert('Walah');
					});
					
					jQuery('<br><hr><br>').appendTo(fillEl);
				}
				//fillEl.html(entStr);
			});
		}
		var g = new google.feeds.Feed(opts.url);
		g.setNumEntries(opts.max);
		g.load(resLoaded);
		//setTimeout("g.load(resLoaded)",600000);
		return this;
	};
})(jQuery);